/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ai.gui;

import ai.Brain;
import ai.backbrop.BackPropBrain;
import ai.backbropPlus.BackPropPlusBrain;
import ai.convolution.ConvolutionBrain;
import ai.convolution.LayerConfig;
import ai.perceptron.SingleLayerPerceptronBrain;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.JFrame;

/**
 *
 * @author pjl
 */
public class Actions {

    Vector<AbstractAction> actions;

    void createBrainFrame(AbstractAction act,Brain b) {
        try {
            JFrame frame=new AIBrainFrame(b);
            frame.setTitle((String) act.getValue(AbstractAction.NAME));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(AIBrainFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(AIBrainFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(AIBrainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    Actions(final Dimension dIn, final Dimension dOut) {

        actions = new Vector<AbstractAction>();

        actions.add(new AbstractAction("Single Layer Perceptron") {

            public void actionPerformed(ActionEvent e) {
                createBrainFrame(this,new SingleLayerPerceptronBrain(dIn, dOut));
            }
        });

        actions.add(new AbstractAction("Back Propagation (no hidden)") {

            public void actionPerformed(ActionEvent e) {
                int hidden[] = new int[]{};
                createBrainFrame(this,new BackPropBrain(dIn, dOut, hidden, .001, 40.0));
            }
        });

        actions.add(new AbstractAction("Back Propagation (hidden 4)") {

            public void actionPerformed(ActionEvent e) {
                int hidden[] = new int[]{4};
                createBrainFrame(this,new BackPropBrain(dIn, dOut, hidden, .001, 40.0));
            }
        });




        actions.add(new AbstractAction("Back Propagation (hidden 10)") {

            public void actionPerformed(ActionEvent e) {
                int hidden[] = new int[]{10};
                createBrainFrame(this,new BackPropBrain(dIn, dOut, hidden, .001, 40.0));
            }
        });



        actions.add(new AbstractAction("Back Propagation (hidden 88)") {

            public void actionPerformed(ActionEvent e) {
                int hidden[] = new int[]{88};
                createBrainFrame(this,new BackPropBrain(dIn, dOut, hidden, .001, 40.0));
            }
        });


        actions.add(new AbstractAction("Back Propagation (hidden 176,20)") {

            public void actionPerformed(ActionEvent e) {
                int hidden[] = new int[]{176, 20};
                createBrainFrame(this,new BackPropBrain(dIn, dOut, hidden, .001, 40.0));
            }
        });



        actions.add(new AbstractAction("Back Prop Plus") {

            public void actionPerformed(ActionEvent e) {
                //     int hidden[] = new int[]{80};
                createBrainFrame(this,new BackPropPlusBrain(dIn, dOut));
            }
        });




        actions.add(new AbstractAction("Convolution back propagation (deprecated)") {

            public void actionPerformed(ActionEvent e) {
                createBrainFrame(this,new ConvolutionBrain(dIn, dOut));
            }
        });




        actions.add(new AbstractAction("Layer brain (1 layer)") {

            public void actionPerformed(ActionEvent e) {
                createBrainFrame(this,LayerConfig.createConvolutionBrain1(dIn, dOut));
            }
        });


        actions.add(new AbstractAction("Layer(10-10) brain") {

            public void actionPerformed(ActionEvent e) {
                createBrainFrame(this,LayerConfig.createConvolutionBrain3(dIn, dOut, 10));
            }
        });


        actions.add(new AbstractAction("Layer  (20-10) brain") {

            public void actionPerformed(ActionEvent e) {
                createBrainFrame(this,LayerConfig.createConvolutionBrain3(dIn, dOut, 20));
            }
        });


        actions.add(new AbstractAction("Layer 1x1 (x6) silly brain") {

            public void actionPerformed(ActionEvent e) {
                createBrainFrame(this,LayerConfig.createConvolutionBrain4(dIn, dOut, 6));
            }
        });


        actions.add(new AbstractAction("Layer(8x8 (x6)) brain") {

            public void actionPerformed(ActionEvent e) {
                createBrainFrame(this,LayerConfig.createConvolutionBrain5(dIn, dOut, 6, 8));
            }
        });

        actions.add(new AbstractAction("Layer(8x8 (x8) | 5 ) brain") {

            public void actionPerformed(ActionEvent e) {
                System.out.println("Hello X");
                createBrainFrame(this,LayerConfig.createConvolutionBrain6(dIn, dOut, 8, 8, 20));
            }
        });

    }
}
